<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Get the current mock for a class</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.uopz-get-hook.html">« uopz_get_hook</a></li>
      <li style="float: right;"><a href="function.uopz-get-property.html">uopz_get_property »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.uopz.html">Uopz 函数</a></li>
    <li>Get the current mock for a class</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.uopz-get-mock" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">uopz_get_mock</h1>
  <p class="verinfo">(PECL uopz 5, PECL uopz 6, PECL uopz 7)</p><p class="refpurpose"><span class="refname">uopz_get_mock</span> &mdash; <span class="dc-title">Get the current mock for a class</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.uopz-get-mock-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>uopz_get_mock</strong></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$class</code></span>): <span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span></div>

  <p class="para rdfs-comment">
   Returns the current mock for <code class="parameter">class</code>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.uopz-get-mock-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt>
<code class="parameter">class</code></dt>

    <dd>

     <p class="para">
 The name of the mocked class.
     </p>
    </dd>

   
  </dl>

 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.uopz-get-mock-returnvalues">
    <h3 class="title">返回值</h3>
      <p class="para">
         Either a string containing the name of the mock, or an object,
         or <strong><code>null</code></strong> if no mock has been set.
      </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.uopz-get-mock-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-625">
   <p><strong>示例 #1 <span class="function"><strong>uopz_get_mock()</strong></span> example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">A&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;static&nbsp;function&nbsp;</span><span style="color: #0000BB">who</span><span style="color: #007700">()&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"A"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /><br />class&nbsp;</span><span style="color: #0000BB">mockA&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;static&nbsp;function&nbsp;</span><span style="color: #0000BB">who</span><span style="color: #007700">()&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"mockA"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /><br /></span><span style="color: #0000BB">uopz_set_mock</span><span style="color: #007700">(</span><span style="color: #0000BB">A</span><span style="color: #007700">::class,&nbsp;</span><span style="color: #0000BB">mockA</span><span style="color: #007700">::class);<br />echo&nbsp;</span><span style="color: #0000BB">uopz_get_mock</span><span style="color: #007700">(</span><span style="color: #0000BB">A</span><span style="color: #007700">::class);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>以上例程会输出：</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
mockA
</pre></div>
   </div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.uopz-get-mock-seealso">
  <h3 class="title">参见</h3>
  <ul class="simplelist">
   <li class="member"><span class="function"><a href="function.uopz-set-mock.html" class="function" rel="rdfs-seeAlso">uopz_set_mock()</a> - Use mock instead of class for new objects</span></li>
   <li class="member"><span class="function"><a href="function.uopz-unset-mock.html" class="function" rel="rdfs-seeAlso">uopz_unset_mock()</a> - Unset previously set mock</span></li>
  </ul>
 </div>


</div></div></div></body></html>